#include<iostream>
using namespace std;
size_t rp = 0;//逆序对reverse pair
int a[100001], t[100001];

void mergesort(int left, int right)
{
	if (left >= right)
		return;
	int mid = 0;
	mid = left + (right - left) / 2;
	mergesort(left, mid);
	mergesort(mid + 1, right);
	int l = left, r = mid + 1, num = left;
	while (l <= mid && r <= right)
	{
		if (a[l] <= a[r])
			t[num++] = a[l++];
		else
		{
			t[num++] = a[r++];
			rp += size_t(mid) - size_t(l) + size_t(1);
		}
	}
	while (l <= mid)
		t[num++] = a[l++];
	while (r <= right)
		t[num++] = a[r++];
	for (int i = left; i <= right; i++)
		a[i] = t[i];
}

int main()
{
	cin >> a[0];
	for (int i = 1; i <= a[0]; i++)
		cin >> a[i];
	mergesort(1, a[0]);
	cout << rp;
	return 0;
}